package january4;

import java.util.Scanner;

/**
 * ClassName: PrimeEightPrint
 * Package: january4
 * Description:判断一定范围内的素数，并按照每行八个打印输出
 *
 * @Author fjorid
 * @Create 2025/1/4 18:45
 * @Version 1.0
 */
public class PrimeEightPrint {
    public static void main(String[] args) {
        int lowerBound,previousBound;
        boolean isPrime = true;
        int temp =0;
        int n =0;
        int count =0;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入所求范围的下届");
        lowerBound = scanner.nextInt();
        System.out.println("请输入所求范围的上届");
        previousBound = scanner.nextInt();
        for (int i = lowerBound; i <= previousBound ; i++){
            for (int j = 2; j <= Math.sqrt(i); j++) {
                isPrime = true;
                if(i%j == 0){
                    isPrime = false;
                    break;
                }
            }
            if(isPrime){
                System.out.print(i+" ");
                n++;
                count++;
                if(n%8==0){
                    System.out.print("\n");
                }
            }



        }
        System.out.println(count);

    }

}
